{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=2981
  Verdict: Accepted
}
uses
  SysUtils;
var a,b:array[1..3] of longint; i,max,maxa:longint;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(a[1],a[2],a[3]);
readln(b[1],b[2],b[3]);
max:=1;
for i:=2 to 3 do if a[i]>a[max] then max:=i;
maxa:=1;
for i:=2 to 3 do if b[i]>b[maxa] then maxa:=i;
if a[max]>b[maxa] then writeln(a[1]+a[2]+a[3]+b[1]+b[2]+b[3]-2*b[maxa]) else writeln(a[1]+a[2]+a[3]+b[1]+b[2]+b[3]-2*a[max]);
close(input);
close(output);
end.